IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_RoleMapping_Group]') AND parent_object_id = OBJECT_ID(N'[dbo].[RoleMapping]'))
ALTER TABLE [dbo].[RoleMapping] DROP CONSTRAINT [FK_RoleMapping_Group]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_RoleMapping_Role1]') AND parent_object_id = OBJECT_ID(N'[dbo].[RoleMapping]'))
ALTER TABLE [dbo].[RoleMapping] DROP CONSTRAINT [FK_RoleMapping_Role1]
GO

/****** Object:  Table [dbo].[RoleMapping]    Script Date: 08/05/2009 14:27:57 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[RoleMapping]') AND type in (N'U'))
DROP TABLE [dbo].[RoleMapping]
GO

/****** Object:  Table [dbo].[RoleMapping]    Script Date: 08/05/2009 14:27:57 ******/
SET ANSI_NULLS ON
GO

CREATE TABLE [dbo].[RoleMapping](
	[RoleMappingID] [int] IDENTITY(1,1) NOT NULL,
	[GroupID] [int] NOT NULL,
	[RoleID] [int] NOT NULL,
	[CreatedBy] [nvarchar](50) NOT NULL,
	[CreatedDate] [datetime] NOT NULL,
 CONSTRAINT [PK_RoleMapping] PRIMARY KEY CLUSTERED 
(
	[RoleMappingID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[RoleMapping]  WITH CHECK ADD  CONSTRAINT [FK_RoleMapping_Group] FOREIGN KEY([GroupID])
REFERENCES [dbo].[AuthorizationGroup] ([GroupID])
GO

ALTER TABLE [dbo].[RoleMapping] CHECK CONSTRAINT [FK_RoleMapping_Group]
GO

ALTER TABLE [dbo].[RoleMapping]  WITH CHECK ADD  CONSTRAINT [FK_RoleMapping_Role1] FOREIGN KEY([RoleID])
REFERENCES [dbo].[Role] ([RoleID])
GO

ALTER TABLE [dbo].[RoleMapping] CHECK CONSTRAINT [FK_RoleMapping_Role1]
GO


